@using MudBlazor

<MudPaper class="d-flex justify-between align-center mt-2 px-4 py-2">
    <MudSpacer />
    <div style="width:100px;" class="mr-1">
        <MudSelect T="int" Value="PageInfo.Size" ValueChanged="PageSizeChanged" Variant="Variant.Outlined" Label="每页条数"
                   Margin="Margin.Dense" Class="search-com">
            <MudSelectItem Value="10">10</MudSelectItem>
            <MudSelectItem Value="20">20</MudSelectItem>
            <MudSelectItem Value="50">50</MudSelectItem>
            <MudSelectItem Value="100">100</MudSelectItem>
        </MudSelect>
    </div>

    <MudPagination Color="Color.Primary" Count="@((PageInfo.Total - 1)/PageInfo.Size + 1)" Selected="@PageInfo.Page"
                   SelectedChanged="PageChangedClick" Variant="Variant.Outlined" Rectangular="true" />
</MudPaper>



@code {
    [Parameter] public PaginationModel PageInfo { get; set; } = null!;

    [Parameter] public EventCallback<int> PageChangedClick { get; set; }

    private void PageSizeChanged(int size)
    {
        PageInfo.Size = size;
        PageInfo.Page = 1;
        PageChangedClick.InvokeAsync(PageInfo.Page);
    }


    public record PaginationModel
    {
        public int Page { get; set; } = 1;

        public int Size { get; set; } = 10;

        public int Total { get; set; } = 0;
    }
}
